package regex;

import static utils.BaseConstants.EMPTY;

import utils.StringUtils;

public class CharUtils {
    private static final char CHAR1 = '\1';
    private static final char CHAR2 = '\2';

    public static char getInvisibleChar1() {
        return CHAR1;
    }

    public static char getInvisibleChar2() {
        return CHAR2;
    }

    public static String getOriginName(String name) {
        if (StringUtils.isEmpty(name)) {
            return EMPTY;
        }

        return name.replaceAll("[" + getInvisibleChar1() + getInvisibleChar2() + "]", EMPTY);
    }

    public static boolean containInvisibleChar1(String data) {
        return !StringUtils.isEmpty(data) && data.contains(String.valueOf(CharUtils.getInvisibleChar1()));
    }

    public static boolean isMatchAllName(String name) {
        return !StringUtils.isEmpty(name) && name.length() > 2
            && name.charAt(0) == CHAR1 && name.charAt(name.length() - 1) == CHAR2;
    }
}
